
<style>
    .we7-table>tbody>tr>td{
        padding:4px 0px;
    }
    .img-thumbnail{
        height: 40px; width: 40px;
    }
</style>




{if $rd=='add'}
    {template 'option/fourm_add'} 
{else} 
<div class="panel panel-default" style=" ">
	<ul class="nav nav-tabs" style="margin-top: 5px;padding-left: 10px;">
	
		<li class="{if (empty($rd) || $rd=='index')}active{/if}">
		<a href="{php echo $this->createWebUrl('option', array('op' => $operation))}"> 管理</a></li>
		<li  class="{if ( $rd=='add')}active{/if}">
		<a href="{php echo $this->createWebUrl('option', array('op' => $operation,'rd'=>'add'))}">新增 </a></li>
	
	</ul>	
    <div class="panel-body"> 

<form action="{php echo $this->createWebUrl('option', array('op' => $operation,'rd'=>'delete'))}" class="we7-form" method="post">
<table class="table we7-table table-hover article-list vertical-middle" id="js-wesite-category-display">
	 
	<tr>
		<th width="5%"></th>
		<th  width="5%">排序</th>
		<th  width="10%">名称</th>		
        <th  width="5%">图标1</th>
        {if $operation=='btbar'} 
		<th  width="5%">图标2</th>
		{/if}
		<th  width="35%">链接URL</th>
        <th  width="5%">启用</th>
		<th  width="10%" class="text-right">操作</th>
	</tr>
	{loop $category $row}
		<tr>
			<td>
				<input type="checkbox" we7-check-all="1" name="rid[]" id="rid-{$row['id']}" value="{$row['id']}">
				<label for="rid-{$row['id']}">&nbsp;</label>
			</td>
			<td class="text-left">{$row['orderid']}</td>
			<td class="text-left">
                
				<span>{$row['fname']}</span>
			</td>
			<td>
                <img width="32" height="32" src="<?php echo tomedia($row['thumb']);?>">
            </td>
			{if $operation=='btbar'}
            <td>
                <img width="32" height="32" src="<?php echo tomedia($row['thumb_active']);?>">
            </td>
			{/if}
			<td style="padding:10px;">
				{if $row['desc']}
				  {$open_target[$row['islink']]}：  {$row['desc']}
				{else} 未填写 {/if}
			</td>
			<td>
				<label>
					<div class="switch switch{php echo $row['disabled'] ? 'Off' : 'On'}" onclick="changeStatus({$row['id']})"></div>
				</label>
			</td> 
			<td style="position: relative;"> 
				<div class="link-group">
				 
					<a href="{php echo $this->createWebUrl('option', array('op'=>$operation,'rd'=>'add','id' => $row['id']));}" >编辑</a>
					<a href="{php echo $this->createWebUrl('option', array('op'=>$operation,'rd'=>'delete','id' => $row['id']));}" class="del" onclick="return confirm('确认删除此分类吗？');return false;">删除</a>
				</div>
                            
			</td>
		</tr>
		 
	{/loop}
</table>
<div class="clearfix"></div>
<div class="we7-margin-left">
	<input type="checkbox" we7-check-all="1" name="rid[]" id="select_all" value="1">
	<label for="select_all">&nbsp;</label>
	<input type="submit" class="btn btn-danger" name="submit" value="删除" onclick="if(!confirm('确定删除选中的规则吗？')) return false;"/>
	<input type="hidden" name="token" value="{$_W['token']}" />	
</div>
</form>
</div>
</div>
<script>
$('#select_all').click(function(){
	$('.article-list :checkbox').prop('checked', $(this).prop('checked'));
});
$('.js-clip').each(function(){
	util.clip(this, $(this).attr('data-url'));
});
var changeStatus = function(id) {
	var id = parseInt(id);
	$.post("{php echo $this->createWebUrl('option', array('op' =>$operation,'rd'=> 'change_status'))}",  {id: id},function(data) {
		if (data.message.errno == 0){
			util.message(data.message.message, data.redirect, 'success');
		} else {
			if (data.message.errno == 1) util.toast('更改失败！', 'error');
			if (data.message.errno == -1) util.toast('分类不存在，请刷新重试！');
		}
	}, 'json');
}
</script>

{/if}